package com.lljin.study.userserviceprovider.config;

import com.lljin.study.client.OrderServiceMark;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.time.Duration;

/**
 * @author lljin
 * @description TODO
 * @date 2020/7/20 0:18
 */
@EnableHystrix
@EnableFeignClients(basePackages = "com.lljin.study.service", basePackageClasses = OrderServiceMark.class)
@Configuration
public class RootConfiguration {

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        //设置4秒的超时时间
        builder.setConnectTimeout(Duration.ofSeconds(4));
        return builder.build();
    }
}
